//
//  QDAttentionCell.m
//  simulateQuickDoctor
//
//  Created by 姚华杰 on 2017/3/25.
//  Copyright © 2017年 PipiXia. All rights reserved.
//

#import "QDAttentionCell.h"
#import <UIImageView+WebCache.h>
@interface QDAttentionCell ()

@property (weak, nonatomic) IBOutlet UIImageView *imgView;

@property (weak, nonatomic) IBOutlet UILabel *nameLabel;

@property (weak, nonatomic) IBOutlet UILabel *sortLabel;

@property (weak, nonatomic) IBOutlet UILabel *hospitalNameLabel;

@property (weak, nonatomic) IBOutlet UILabel *bespeakNUmLabel;

@property (weak, nonatomic) IBOutlet UILabel *flowersNumLabel;

@property (weak, nonatomic) IBOutlet UILabel *jinqiNumLabel;

@end
@implementation QDAttentionCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)setModel:(QDDAModel *)model
{
    _model = model;
    
//    NSLog(@"%@",_model.doctor_portrait);
    
   [_imgView sd_setImageWithURL:[NSURL URLWithString:model.doctor_portrait] placeholderImage:[UIImage imageNamed:@"doctor_defaultphoto_male"]];
    
    [self clipIcon:_imgView];
    
    _nameLabel.text = model.doctor_name;
    
    _sortLabel.text = model.doctor_title_name;
    
//    _hospitalNameLabel.text = model.doctor_hospital_name;
    
    _bespeakNUmLabel.text = @(model.operation_count).description;
    
    _flowersNumLabel.text = @(model.flower).description;
    
    _jinqiNumLabel.text = @(model.banner).description;
}


- (void)clipIcon:(UIImageView*)iconView{
    
    //加载图片
    UIImage *image = [UIImage imageNamed:@"doctor_defaultphoto_male.png"];
    
    //获取图片尺寸
    CGSize size = image.size;
    
    //开启位图上下文
    UIGraphicsBeginImageContextWithOptions(size, NO, 0);
    
    //创建圆形路径
    UIBezierPath *path = [UIBezierPath bezierPathWithOvalInRect:CGRectMake(0, 0, image.size.width, image.size.height)];
    
    //设置为裁剪区域
    [path addClip];
    
    //绘制图片
    [image drawAtPoint:CGPointZero];
    
    //获取裁剪后的图片
    iconView.image = UIGraphicsGetImageFromCurrentImageContext();
    
    //关闭上下文
    UIGraphicsEndImageContext();
    
}

@end
